home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / ffield.zip / UNION.QC < prev    next >
Text File  |  1996-10-28  |  5KB  |  131 lines

  1. // Declare procedures that are defined in other .qc files...
  2. void(entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  3. float ()crandom;
  4.  
  5. /*
  6. =======================================
  7. UnionCycleForceField
  8. =======================================
  9. This procedure cycles the force field on and off
  10. */
  11.  
  12. void(entity PlayerFFCycle) UnionCycleForceField =
  13. {
  14.         if (PlayerFFCycle.Union_ForceField_On == TRUE)
  15.     // If the FF is on...
  16.     {
  17.         // Tell the player, turn of the FF and the glow
  18.                 sprint(PlayerFFCycle, "Force Field Deactivated...\n");
  19.                 sound(PlayerFFCycle,CHAN_AUTO,"sound/FF/FF_Off.wav",1,ATTN_NORM);
  20.                 PlayerFFCycle.Union_ForceField_On = FALSE;
  21.                 PlayerFFCycle.effects = 0;
  22.     }
  23.     else
  24.     // If the FF is off
  25.     {
  26.                 if (PlayerFFCycle.Union_FF_HasItem == TRUE)
  27.                 // Make sure that player has it
  28.         {
  29.                         if (PlayerFFCycle.ammo_cells < 1)
  30.             // If player doesn't have cells
  31.             {
  32.                 // Tell the player 
  33.                                 sprint(PlayerFFCycle, "Cannot activate.  No cells...\n");
  34.                                 // Buzz noise?
  35.             }
  36.             else
  37.             // Player has cells so turn on the FF
  38.             {
  39.                 // Tell the player, turn on the FF and the effect.
  40.                                 sprint(PlayerFFCycle, "Force Field Activated...\n");
  41.                                 sound(PlayerFFCycle,CHAN_AUTO,"sound/FF/FF_On.wav",1,ATTN_NORM);
  42.                                 PlayerFFCycle.Union_ForceField_On = TRUE;
  43.                                 PlayerFFCycle.effects = EF_DIMLIGHT;
  44.             }
  45.         }
  46.         else
  47.                 // Player doesn't have it
  48.         {
  49.                         sprint(PlayerFFCycle, "You don't have the Force Field\n");
  50.         }
  51.     }
  52. };
  53.  
  54.  
  55. /*
  56. =======================================
  57. UnionFFRot
  58. =======================================
  59. This procedure slowly drains cells from the player
  60. and other things that need to be checked periodically.
  61. */
  62.  
  63. void(entity PlayerFFRot) UnionFFRot =
  64. {
  65.         if (PlayerFFRot.Union_ForceField_On)
  66.         {
  67.                 if (PlayerFFRot.waterlevel > 1)
  68.                 // When in water, the FF shorts out
  69.                 // and damages the player
  70.                 {
  71.                         UnionCycleForceField(PlayerFFRot);
  72.                         T_Damage(PlayerFFRot, PlayerFFRot, PlayerFFRot, PlayerFFRot.ammo_cells);
  73.                         PlayerFFRot.ammo_cells = 0;
  74.                         stuffcmd (PlayerFFRot, "bf\n");
  75.                         sound(PlayerFFRot,CHAN_AUTO,"sound/FF/FF_Water.wav",1,ATTN_NORM);
  76.                         return;
  77.                 }
  78.                 if (PlayerFFRot.UnionForceFieldRotTime <= time)
  79.                 // Draing cells from the player to maintain the field.
  80.                 {
  81.                         PlayerFFRot.ammo_cells = PlayerFFRot.ammo_cells - 1;
  82.                         // If the current weapon is the lightning gun, need
  83.                         // to change the current ammo to keep it accurate
  84.                         if (PlayerFFRot.weapon == IT_LIGHTNING)
  85.                                 PlayerFFRot.currentammo = PlayerFFRot.currentammo - 1;
  86.                         // Update variable for next rot time
  87.                         PlayerFFRot.UnionForceFieldRotTime = time + 1;
  88.                         if (PlayerFFRot.ammo_cells < 1)
  89.                                 UnionCycleForceField(PlayerFFRot);
  90.                 }
  91.         }
  92. };
  93.  
  94.  
  95. // This function is called from T_damage.  It reduces the amount of
  96. // damage a player takes by using 1 cell per 5 damage.  It returns
  97. // any leftover damage to T_damage for normal damage resolution.
  98. float(entity UnionTarget, float UnionDamage) UnionFFTakeDamage =
  99. {
  100.         if (UnionTarget.ammo_cells < 1)
  101.         // No cells left for force field so turn it off and return any
  102.         // damage that's letf.
  103.         {
  104.                 UnionTarget.Union_ForceField_On = FALSE;
  105.                 UnionTarget.effects = 0;
  106.                 sprint(UnionTarget, "Force Field Depleated!!!\n");
  107.                 return UnionDamage;
  108.         }
  109.         if (UnionDamage < 1)
  110.         // No damage left
  111.                 return 0;
  112.         if (UnionDamage > 118)
  113.         // If the force field takes more than 100 damage in a single hit,
  114.         // it overloads and player looses item.
  115.                 {
  116.                 UnionTarget.Union_ForceField_On = FALSE;
  117.                 UnionTarget.Union_FF_HasItem = FALSE;
  118.                 UnionTarget.ammo_cells = 0;
  119.                 UnionTarget.effects = 0;
  120.                 sprint(UnionTarget, "Force Field Overloaded!!!\n");
  121.                 stuffcmd (UnionTarget, "bf\n");
  122.                 sound(UnionTarget,CHAN_AUTO,"sound/FF/FF_water.wav",1,ATTN_NORM);
  123.                 return UnionDamage;
  124.                 }
  125.         // Player still has cells and some damage that's not resolved.
  126.         // Take away a cell, remove 5 damage points, and recheck
  127.         UnionTarget.ammo_cells = UnionTarget.ammo_cells - 1;
  128.         UnionDamage = UnionDamage - 5;
  129.         return UnionFFTakeDamage (UnionTarget, UnionDamage);
  130. };
  131.